package com.azxc.rapid.plus.system.service.impl;


import com.azxc.rapid.core.mp.support.Condition;
import com.azxc.rapid.plus.system.mapper.DictBizPlusMapper;
import com.azxc.rapid.plus.system.service.IDictBizPlusService;
import com.azxc.rapid.plus.system.wrapper.DictBizWrapper;
import com.azxc.rapid.system.cache.DictBizCache;
import com.azxc.rapid.system.entity.DictBiz;
import com.azxc.rapid.system.vo.DictBizVO;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * 服务实现类
 */
@Service
public class DictBizPlusServiceImpl extends ServiceImpl<DictBizPlusMapper, DictBiz> implements IDictBizPlusService {


	@Override
	public List<DictBizVO> childList(Map<String, Object> dict, Long parentId) {
		if (parentId < 0) {
			return new ArrayList<>();
		}
		dict.remove("parentId");
		DictBiz parentDict = DictBizCache.getById(parentId);
		List<DictBiz> list = this.list(Condition.getQueryWrapper(dict, DictBiz.class).lambda().ne(DictBiz::getId, parentId).eq(DictBiz::getCode, parentDict.getCode()).orderByAsc(DictBiz::getSort));
		return DictBizWrapper.build().listNodeVO(list);
	}
}
